package person.tanjinfu.jaegerexample;

import io.jaegertracing.Configuration;
import io.jaegertracing.internal.samplers.ConstSampler;
import io.opentracing.Tracer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class JaegerExampleCalleeApplication {

    public static void main(String[] args) {
        SpringApplication.run(JaegerExampleCalleeApplication.class, args);
    }

    @Bean
    public Tracer tracer() {
        return new Configuration("jaeger-example-callee")
                .withSampler(Configuration.SamplerConfiguration.fromEnv()
                        .withType(ConstSampler.TYPE)
                        .withParam(1)
                )
                .withReporter(Configuration.ReporterConfiguration.fromEnv()
                        .withFlushInterval(1000)
                        .withLogSpans(true)
                        .withMaxQueueSize(1000)
                        .withSender(Configuration.SenderConfiguration.fromEnv()
                                .withAgentHost("localhost")
                                .withAgentPort(6831)
                        )
                )
                .getTracer();
    }


}
